<?php
    $servername = "localhost";
    $username = "root";
    $password = "123456";
    $dbname = "hanwei";
?>
<?php
 // error_reporting(0);//设置不出现任何警告
 // Session需要先启动。
 session_start();
 //判断uname和pwd是否赋值
 if(isset($_POST['name']) && isset($_POST['pwd'])){
     $name = $_POST['name'];
     $pwd = $_POST['pwd'];
     //连接数据库

   //$conn = new mysqli($servername, $username, $password, $dbname);
     $conn=mysql_connect($servername,$username,$password) or die("error connecting") ; //连接数据库

    mysql_query("set names 'utf8'"); //数据库输出编码 应该与你的数据库编码保持一致.南昌网站建设公司百恒网络PHP工程师建议用UTF-8 国际标准编码.

    mysql_select_db($dbname); //打开数据库

   $sql="INSERT INTO user values ($name,$pwd)";//INSERT INTO user(user,password) VALUE ('$name','$pwd');
   
   $res = mysql_query($sql);
   
   

   $row=mysql_affected_rows($conn);
   
   if($row>0)

{

 
  echo "<script> alert('注册成功 即将跳转到登录页面');parent.location.href='/920/login.php'; </script>";

}else{

   echo "<script>alert('注册失败 该用户名已存在');</script>";

}
 }
 
?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>注册 - 素材牛模板演示</title>  
    <link rel="stylesheet" href="css/pintuer.css">
    <link rel="stylesheet" href="css/admin.css">
    <script src="js/jquery.js"></script>
    <script src="js/pintuer.js"></script>  
</head>
<body>
<div class="bg"></div>
<div class="container">
    <div class="line bouncein">
        <div class="xs6 xm4 xs3-move xm4-move">
            <div style="height:150px;"></div>
            <div class="media media-y margin-big-bottom">           
            </div>         
            <form  method="post">
            <div class="panel loginbox">
                <div class="text-center margin-big padding-big-top"><h1>注册中心</h1></div>
                <div class="panel-body" style="padding:30px; padding-bottom:10px; padding-top:10px;">
                    <div class="form-group">
                        <div class="field field-icon-right">
                            <input type="text" class="input input-big" name="name" placeholder="注册的用户名" data-validate="required:请填写账号" />
                            <span class="icon icon-user margin-small"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="field field-icon-right">
                            <input type="password" class="input input-big" name="pwd" placeholder="登录密码" data-validate="required:请填写密码" />
                            <span class="icon icon-key margin-small"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        
                    </div>
                </div>
                <div style="padding:30px;"><input type="submit" class="button button-block bg-main text-big input-big" value="注册">
                  <a href="/920/login.php" >已有账号？点击登录</a>
                </div>
                
            </div>
            </form>          
        </div>
    </div>
</div>

</body>
</html>